<?php  

  $query = mysql_query("SELECT * FROM tutorials_categorys") or die(mysql_error());

        //if the number of rows returned is 0, then say, no categories
        if (mysql_num_rows($query) == 0) {
            echo "No tutorial categories currently!";
        }
        //if anything else, then there has to be categories. show em.
        else {
            echo "<h1>Tutorial Categories:</h1> ";
            //while loop to loop through the database and display results!
            while ($row = mysql_fetch_array($query)) {
                echo "
            <table border='0' cellpadding = '0' cellspacing='0' width='500'>
                <tr>
                    <td>Category Name:</td>
                    <td>$row[category]</td>
                </tr>
                <tr>
                    <td>Description:</td>
                    <td>$row[description]</td>
                </tr>
                <tr>
                    <td><a href='$self?action=viewcategory&id=$row[id]'>Visit this category</a></td>
                </tr>
                <tr>
                    <td><hr /></td>
                </tr>
            </table>
            ";
            }
        }
?>